package com.blog.config;

import com.blog.Utils.AliOssUtil;
import com.blog.properties.AliOssProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 任浩
 * @version 1.0
 */

@Configuration
@Slf4j
public class AliOssConfig {

    //这个类是一个配置类
    @Bean
    @ConditionalOnMissingBean // 如果没有这个配置类，就进行创建这个bean
    public AliOssUtil aliOssUtil (AliOssProperties aliOssProperties){
        return new AliOssUtil(aliOssProperties.getEndpoint(),
                aliOssProperties.getAccessKeyId(),
                aliOssProperties.getAccessKeySecret(),
                aliOssProperties.getBucketName());
    }

}
